// pages/mange/album/list.js
Page({
  mixins: [require('../../../wechat-lib/themeChanged')],
  
  selectResult: function (e) {
    console.log('select result', e.detail)
    wx.navigateTo({
      url: '../chenyu/detail?name='+e.detail.item.text,
    })
  },
  search: function (value) {
    debugger
    console.log(value)
  },
  data: {
    slideButtons: [{
      type: 'warn',
      text: '删除',
    },{
      type: 'default',
      text: '置顶',
    }],
    collectList: [{}]
  },
  slideButtonTap(e) { 
    const collectList=this.data.collectList
    const _that=this
    if (e.detail.index==0 && e.currentTarget.dataset.title!=undefined){
      console.log("delete",e.currentTarget.dataset.title)
      wx.cloud.callFunction(
        {
          name:"collect",
          data:{
            title:e.currentTarget.dataset.title,
            action:'deleteCollect'
          }
        }
      ).then(res=>{
        console.log("delete success")
        console.log(collectList)
        collectList.splice(collectList.findIndex(item=>item.title===e.currentTarget.dataset.title),1)
        console.log(collectList)
        _that.setData(
          {
            collectList:collectList
          }
        )
      },err=>{
        console.err("delete error",err)
      })
    }
  },
  jumpDetail(e){
    console.log(e)
    wx.navigateTo({
      url: '../chenyu/detail?name='+e.currentTarget.dataset.title,
    })
  }
})